if (TARGET tinyusb_device)
add_executable(PicoClock
        PicoClock.c
        breathing_led.c
        led.c
        ds3231_rtc.c
        ht1621b.c
        segment_codes.c
        buzzer.c
        alarm.c
        countdown.c
        rotary_encoder.c
        key_handler.c
        )
cmake_minimum_required(VERSION 3.15)

set(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/../freertos)
include(FreeRTOS_Kernel_import.cmake)

# pull in common dependencies
target_link_libraries(PicoClock pico_stdlib hardware_spi hardware_i2c hardware_pwm hardware_gpio hardware_dma FreeRTOS-Kernel  FreeRTOS-Kernel-Heap1 )
target_include_directories(PicoClock PRIVATE
         ${CMAKE_CURRENT_LIST_DIR}
        ${FREERTOS_KERNEL_PATH}/include
        )

add_library(freertos_config INTERFACE)

target_include_directories(freertos_config SYSTEM
INTERFACE
./
    include
)

target_compile_definitions(freertos_config
  INTERFACE
    projCOVERAGE_TEST=0
)
if (DEFINED FREERTOS_SMP_EXAMPLE AND FREERTOS_SMP_EXAMPLE STREQUAL "1")
    message(STATUS "Build FreeRTOS SMP example")
    # Adding the following configurations to build SMP template port
    add_compile_options( -DconfigNUMBER_OF_CORES=2 -DconfigUSE_PASSIVE_IDLE_HOOK=0 )
endif()
# Select the heap port.  values between 1-4 will pick a heap.
set(FREERTOS_HEAP "4" CACHE STRING "" FORCE)

# Select the native compile PORT
set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE)

# create map/bin/hex file etc.
pico_add_extra_outputs(PicoClock)

# add url via pico_set_program_url
example_auto_set_url(PicoClock)

# enable usb output, disable uart output
pico_enable_stdio_usb(PicoClock 1)
pico_enable_stdio_uart(PicoClock 0)

elseif(PICO_ON_DEVICE)
    message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in the SDK")
endif()
